﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Model;
namespace DAL
{
    public class 房间信息DAL
    {
        //查询
        public static SqlDataReader SelectAll() {
            string sql = "select * from  dbo.RoomType";
            return DBHelper.Zhilianshi(sql,null);
        }
        //添加
        public static int Add() {
            string sql = @"insert into dbo.RoomType(RTName,RTConsume,RTMount,RTIsDisCount) 
values(@RTName,@RTConsume,@RTMount,@RTIsDisCount)";
            List<SqlParameter> li = new List<SqlParameter>(){
                new SqlParameter("@RTName",房间Model.Rname),
                new SqlParameter("@RTConsume",房间Model.RConsume),
                new SqlParameter("@RTMount",房间Model.RMount),
                new SqlParameter("@RTIsDisCount",房间Model.RIsDisCount)
            
            };
            return DBHelper.Update(sql,li.ToArray());
        }
        //修改
        public static int Update() {
            string sql = @"update RoomType set RTName=@RTName,RTIsDisCount=@RTIsDisCount,
RTConsume=@RTConsume,RTMount=@RTMount where RTID=@RTID";
            List<SqlParameter> l = new List<SqlParameter>(){
           
                new SqlParameter("@RTName",房间Model.Rname),
                new SqlParameter("@RTConsume",房间Model.RConsume),
                new SqlParameter("@RTMount",房间Model.RMount),
                new SqlParameter("@RTIsDisCount",房间Model.RIsDisCount),
                 new SqlParameter("@RTID",房间Model.RTID)
            };
            return DBHelper.Update(sql, l.ToArray());
        }
        //查询2
        public static SqlDataReader Select()
        {
            string sql = "select * from dbo.RoomType where RTID=@RTID";
            List<SqlParameter> list = new List<SqlParameter>()
            {
                new SqlParameter("@RTID",Model.房间Model.RTID),
            };

            return DBHelper.Zhilianshi(sql, list.ToArray());
        }
        //删除房间
        public static int DelFangjian(string RTID) {
            string sql = "delete dbo.RoomType where  RTID=@RTID";
            List<SqlParameter> list = new List<SqlParameter>();
            list.Add(new SqlParameter("@RTID",RTID));
            return DBHelper.Update(sql, list.ToArray());
        }
        public static object SelectRTName()
        {
            string sql = @"select COUNT(*) from  dbo.RoomType
where RTName=@RTName";
            List<SqlParameter> list = new List<SqlParameter>()
            {
                new SqlParameter("@RTName",房间Model.Rname)
            };
            return DBHelper.Chadanzhi(sql, list.ToArray());
        }
    }
}
